<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function ucFirst(str) {
        // 基于str重新拼接字符串
        const p1 = str[0].toUpperCase(); //J
        const p2 = str.slice(1); //ohn
        return p1 + p2;
      }
      console.log(ucFirst("john")); //John
    </script>
  </body>
</html>
